package com.ytjj.qmyx.supplychain.common.model.response;

import com.ytjj.qmyx.supplychain.common.model.BankerOrderVO;
import com.ytjj.qmyx.supplychain.common.model.request.ExpressRecordsRequest;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @Description TODO
 * @ClassName OrdersResponse
 * 
 * 
 * @Version 1.0
 **/
@Data
public class OrdersResponse {

    private Integer id;

    /**
     * 订单号
     */
    private String orderNo;

    /**
     * 用户姓名
     */
    private String userName;

    /**
     * 用户电话
     */
    private String userTel;

    /**
     * 商品名字
     */
    private String productName;

    /**
     * 商品价格
     */
    private BigDecimal productPrice;

    /**
     * 收货地址
     */
    private String deliveryAddress;

    /**
     * 备注
     */
    private String note;

    /**
     * 创建时间
     */
    private String createTimeText;
    /**
     * 导入时间
     */
    private String importTimeText;
    /**
     * 导出时间
     */
    private String exportTimeText;

    /**
     * 是否导出
     */
    private Byte isExport;

    /**
     * 快递号
     */
    private String expressNo;

    /**
     * 快递编号
     */
    private String expressCode;

    /**
     * 快递公司名称
     */
    private String expressName;

    /**
     * 订单发货状态
     */
    private Byte orderStatus;

    /**
     * 订单状态
     */
    private Byte status;

    /**
     * 来源
     * @param yxBankerOrder
     */
    private Byte source;

    /**
     * 仓库名称
     */
    private String warehouse;


    /**
     * 供应商名称
     */
    private String bankerName;

    /**
     * 款号
     * @param yxBankerOrder
     */
    private String typeno;

    /**
     * 测评专区栏目
     */
    private String bankerColumnName;

    private String province;

    private String city;

    private String area;

    private String smallNote;

    private String threeSkuId;

    private Byte uploadFlag; //上传标志位 1-成功 0-失败
    /**
     * 商品数量
     */
    private Integer productSum;

    private String returnStatus;

    private String childOrderNo;

    private Integer orderInfoStatus;

    private String orderInfoStatusName;

    /**
     * 是否0元商品
     */
    private Integer isZeroProduct;

    /**
     * 供应商商品id
     */
    private Integer bankerProductId;

    //一级分类
    private String topCategoryTitle;
    //二级分类
    private String categoryTitle;
    //三级分类
    private String bottomCategoryTitle;
    private String productSkuSpec;
    private BigDecimal costPrice;
    private BigDecimal freight;
    private String authenticatedName;
    private String authenticatedCard;
    private String returnGoodStatus;
    private String returnGoodStatusName;
    private String serviceNo;
    private BigDecimal amount;

    private Integer productSpecId;

    private Integer returnGoodsNum;
    /**
     * 销售端编号
     */
    private String shopId;
    /**
     * 订单签收时间
     */
    private Date receiveTime;

    /**
     * 订单签收时间
     */
    private String receiveTimeText;

    /**
     * 订单来源 xxxx、鹏客优选、淘心购
     */
    private String orderSource;

    /**
     * 物流备注
     */
    private String deliveryRemark;

    /**
     * 拆分快递信息
     */
    private String expressRecordStr;

    /**
     * 拆分快递信息记录
     */
    private List<ExpressRecordsRequest> records;

    public OrdersResponse() {
    }

    public OrdersResponse(BankerOrderVO bankerOrderVO) {
        BeanUtils.copyProperties(bankerOrderVO,this);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        this.createTimeText = simpleDateFormat.format(bankerOrderVO.getCreateTime());
        if (null != bankerOrderVO.getImportTime()) {
            this.importTimeText = simpleDateFormat.format(bankerOrderVO.getImportTime());
        }
        if(bankerOrderVO.getExportTime() != null) {
            this.exportTimeText = simpleDateFormat.format(bankerOrderVO.getExportTime());
        }
        if(bankerOrderVO.getReceiveTime() != null) {
            this.receiveTimeText = simpleDateFormat.format(bankerOrderVO.getReceiveTime());
        }
        if (null == bankerOrderVO.getProductSum()) {
            this.productSum = 1;
        }
    }

    public OrdersResponse(BankerOrderVO bankerOrderVO, String expressName) {
        BeanUtils.copyProperties(bankerOrderVO,this);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        this.createTimeText = simpleDateFormat.format(bankerOrderVO.getCreateTime());
        if (null != bankerOrderVO.getImportTime()) {
            this.importTimeText = simpleDateFormat.format(bankerOrderVO.getImportTime());
        }
        if(bankerOrderVO.getExportTime() != null) {
            this.exportTimeText = simpleDateFormat.format(bankerOrderVO.getExportTime());
        }
        this.expressName = expressName;
    }


}
